// pages/report/index.js
import * as echarts from '../../components/ec-canvas/echarts';
import createOption from './option';

Page({
  /**
   * 页面的初始数据
   */
  data: {
    showShare: false,
    options: [
      { name: '微信', icon: 'wechat', openType: 'share' },
      { name: '朋友圈', icon: 'http://www.lzwcl.com/img/pyq.png' }
    ],
    ec: {
      lazyLoad: true
    },
    highEvaluationResult: {},

    sucessApplyRate: '0'
  },
  /** 查看高企评测报告 */
  checkReport () {
    var highEvaluationResult = this.data.highEvaluationResult;
    wx.navigateTo({
      url: '../zhipin/index?highEvaluationResult=' + JSON.stringify(highEvaluationResult),
    });
  },
  goTextAgain () {
    wx.navigateTo({
      url: '../home/index',
    });
  },
  getCharts () {
    var highEvaluationResult = this.data.highEvaluationResult;
    this.ecComponent.init((canvas, width, height, dpr) => {
      const chart = echarts.init(canvas, null, {
        width: width,
        height: height,
        devicePixelRatio: dpr // new
      });
      const data = [highEvaluationResult.technologyNumber, highEvaluationResult.knowledgeNumber, highEvaluationResult.researchNumber, highEvaluationResult.growNumber];
      const i = -1;
      const options = createOption(data, i);
      chart.setOption(options);
      return chart;
    });
  },
  customShare () {
    this.setData({ showShare: true });
  },
  onSelect () {},
  onClose () {
    this.setData({ showShare: false });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.ecComponent = this.selectComponent('#mychart-dom-graph');
    this.setData({
      highEvaluationResult: JSON.parse(options.highEvaluationResult)
    });
    this.getCharts();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})